<template>
  <!-- 头寸维护审核明细页面弹出框-->
  <el-dialog
    title="头寸维护审核明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
  >
    <el-form ref="detailsForm" :model="formData" :rules="rules" label-width="170px">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="交易流水号：" prop="id">
            <el-input v-model="formData.id" placeholder="交易流水号" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12"></el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="录入操作员：" prop="mdTlrno">
            <el-input v-model="formData.mdTlrno" placeholder="" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间：" prop="mdTime">
            <el-date-picker
              v-model="formData.mdTime"
              type="datetime"
              value-format="yyyyMMddHHmmss"
              placeholder=""
              style="width: 100%"
              disabled
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="设置存款准备金余额：" prop="newreserve">
            <ht-amount-input v-model="formData.newreserve" placeholder="设置存款准备金余额" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="设置预留头寸：" prop="newposition">
            <ht-amount-input v-model="formData.newposition" placeholder="设置预留头寸" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approveFn" :loading="isLoading">审核</el-button>
      <el-button type="warning" @click="rejectFn" :loading="isLoading">拒绝</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { approve, reject } from "@/api/cnaps/bizMng/position.js";
import { log } from "util";
import HtAmountInput from "@/views/components/HtAmountInput";

export default {
  name: "ApproveDetails",
  components: { HtAmountInput },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示弹出层
      open: false,
      isLoading: false,
      rules: {
        newreserve: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        newposition: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
      },
    };
  },
  watch: {
    open(val) {
      if (val) {
      }
    },
  },
  mounted() {},
  methods: {
    // 审核方法
    approveFn() {
      this.$refs["detailsForm"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          approve(this.formData)
            .then((res) => {
              this.isLoading = false;
              this.$emit("editComplete", true);
              this.msgSuccess("已审核!");
              this.closeFn();
            })
            .catch((err) => {
              this.isLoading = false;
            });
        }
      });
    },
    // 拒绝方法
    rejectFn() {
      this.$refs["detailsForm"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          reject(this.formData)
            .then((res) => {
              this.isLoading = false;
              this.$emit("editComplete", true);
              this.msgSuccess("已拒绝!");
              this.closeFn();
            })
            .catch((err) => {
              this.isLoading = false;
            });
        }
      });
    },
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
      this.reset();
    },
    show() {
      this.open = true;
    },
  },
};
</script>
<style lang="scss" scoped>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
